import request from '@/utils/request'
import type { ApiResult, BaseIds, PageSchema } from '@/api/api'
import type { Oauth2RegisteredClient, ClientAddDTO, ClientModDTO, ClientQueryDTO } from '@/api/acl/client/type'

const BASE_URL = '/admin/api/v1/acl/client'

const API = {
  BASE_URL,
  PAGE_URL : BASE_URL + '/page',
  LIST_URL : BASE_URL + '/list',
  REMOVE_URL : BASE_URL + '/rm',
}
// 添加客户端信息
export const clientAdd = (data: ClientAddDTO) => {
  return request.post<any, ApiResult<unknown>>(API.BASE_URL, data)
}
// 修改客户端信息
export const clientMod = (data: ClientModDTO) => {
  return request.put<any, ApiResult<unknown>>(API.BASE_URL, data)
}
// 删除客户端信息
export const clientDel = (data: BaseIds) => {
  return request.post<any, ApiResult<unknown>>(API.REMOVE_URL, data)
}
// 查询客户端信息
export const clientList = (data: ClientQueryDTO) => {
  return request.post<any, ApiResult<Oauth2RegisteredClient[]>>(API.LIST_URL, data)
}
// 查询分页数据
export const clientQuery = (data: ClientQueryDTO) => {
  return request.post<any, ApiResult<PageSchema<Oauth2RegisteredClient>>>(API.PAGE_URL, data)
}

